#pragma once
#include <unistd.h>
#include <fcntl.h>
#include <stdlib.h>

#include "Log.hpp"

void SetNonBlock(int sockfd)
{
    int file = fcntl(sockfd, F_GETFL);
    if(file < 0)
        exit(-1);
    lg.LogMessage(Info, "sockfd %d, is set O_NONBLOCK\n", sockfd);
    fcntl(sockfd, F_SETFL, file | O_NONBLOCK);
}